package com.jnc.web.util.gen;

import com.jnc.common.constant.SysConstant;
import org.apache.velocity.app.Velocity;

import java.util.Properties;

/**
 * @Author: jjn
 * @Date: 2018/11/14
 * @Desc: Velocity工厂
 */
public class VelocityFactory {

    /**
     * 初始化vm
     */
    public static void init(){
        Properties pro = new Properties();
        //加载classpath目录下的vm文件
        pro.setProperty("file.resource.loader.class",
                "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
        //定义字符集
        pro.setProperty(Velocity.ENCODING_DEFAULT, SysConstant.CHARSET_NAME);
        pro.setProperty(Velocity.OUTPUT_ENCODING, SysConstant.CHARSET_NAME);
        //初始化Velocity引擎，指定配置Properties
        Velocity.init(pro);
    }
}
